package com.example.qny01.controller;

import com.example.qny01.service.UserService;
import org.springframework.web.bind.annotation.*;
import qny01.pojo.CommonResult;
import qny01.pojo.User;

import javax.annotation.Resource;
@RestController
@CrossOrigin
@RequestMapping("user")
public class UserControler {
    @Resource
    private UserService userService;

    /**
     * 登录方法，查询数据库和密码是否对的上
     * */
    @PostMapping("login")
    public CommonResult login(@RequestBody User user){

        User login = userService.login(user);
        System.out.println(user.toString());
        System.out.println("调用了login方法");
        if (login!=null){
            return new CommonResult(200,"登录成功",login);
        }else
            return new CommonResult(444,"登录失败",null);
    }

}
